<?php

namespace App\Admin\Controllers;

use App\Models\Administrator;
use Dcat\Admin\Admin;
use Dcat\Admin\Http\Controllers\AuthController as BaseAuthController;

class AuthController extends BaseAuthController
{

    public function switchOnline()
    {
        if ($this->guard()->check()) {
            $user = Admin::user();

            $user->online = !$user->online;

            $user->save();
            return $this->response()->success('切换状态成功')->refresh();
        }

        return $this->response()->error('用户Token 已过期.即将刷新页面!')->refresh();
    }

}
